home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Developer Utilities / Installer 4.0.3 SDK / Script Examples / PowerMac vs 68K Rules Example / powerMac.r < prev    next >
Encoding:
Text File  |  1994-11-15  |  12.1 KB  |  406 lines  |  [TEXT/MPS ]

  1. //
  2. //    powerMac.r
  3. //
  4. //        This example demonstrates usage of the Easy and Custom Install frameworks 
  5. //        to create a customized installation depending on whether the target machine 
  6. //        is a Power Macintosh or a 68000 CPU machine.
  7. //
  8. //        All files are installed to folder "PowerMac Rules Example:" on root folder 
  9. //        of selected target volume for the installation.
  10. //
  11. //        NOTE: This example uses Gestalt calls to determine the CPU of the target 
  12. //        machine of the installation. Some machines with STP cards in them are 
  13. //        actually both PowerMac and 68K, but via a Control Panel the user can select 
  14. //        which machine they want their Mac to behave as. This example script will 
  15. //        install the appropriate modules during Easy Install for whichever CPU the 
  16. //        target machine is currently set up as. Because of the STP upgrade card 
  17. //        situation, most scriptwriters will actually want to include all possible 
  18. //        installation scenarios under Custom Install. 
  19. //
  20. //         IMPORTANT: It should be noted that this example portrays TeachText as being 
  21. //        specialized to work on either a Power Macintosh or 68000 machine. There is 
  22. //        no factual basis for this portrayal.  TeachText is used only as an example 
  23. //        and has not mutated while we were not looking.
  24. //
  25. //
  26. //        mark young • 08/18/94
  27. //
  28. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  29. //
  30.  
  31.  
  32. #include "InstallerTypes.r"
  33.  
  34.  
  35. // constants for Gestalt call to determine whether PowerMac or 68K CPU
  36. #define gestaltSystemType            'sysa'  // tells Gestalt to check CPU
  37. #define gestalt68Ksysa                1        // tells Gestalt to look for 68K CPU's
  38. #define gestaltPPCsysa                2        // tells Gestalt to look for PowerMac CPU's
  39.  
  40. // constants for packages, comments, comment text
  41. #define     kPowerMacPackage    100
  42. #define     k68000Package        200
  43. #define     kSeperatorLine        9999
  44.  
  45.  
  46. // • easy install setup
  47.  
  48. // easy install framework uses ID other than 765 or 766
  49. // recommended to always use ID 764
  50. resource 'infr' (764) {
  51.     format0 {{
  52.         // execute first true rule, if none are true then return false
  53.         pickFirst, { 700, 800 },    // check CPU version, if PowerMac then
  54.                                     // install PowerMac, otherwise install
  55.                                     // 68K version
  56.     }}
  57. };
  58.  
  59. // rule that adds Power Macintosh version file to Easy Install
  60. resource 'inrl' (700) {
  61.     format0 {{
  62.         // this returns false unless CPU is Power Macintosh
  63.         CheckGestalt{ gestaltSystemType, { gestaltPPCsysa }},
  64.         
  65.         // if Power Macintosh CPU add that package
  66.         AddPackages{{ kPowerMacPackage }},
  67.         AddUserDescription{ "Install the PowerMac version TeachText to \"PowerMac Rules Example\" folder." },
  68.     }}
  69. };
  70.  
  71. // rule that adds 68K version file to Easy Install
  72. resource 'inrl' (800) {
  73.     format0 {{
  74.         
  75.         // if not a PowerMac, add the 68000 CPU package
  76.         AddPackages{{ k68000Package }},
  77.         AddUserDescription{ "Install the 68K version of TeachText to \"PowerMac Rules Example\" folder." },
  78.     }}
  79. };
  80.  
  81.  
  82. // • custom install setup
  83.  
  84. // custom install framework always uses ID of 766
  85. resource 'infr' (766) {
  86.     format0 {{
  87.         pickAll, { 1000 },        // give choices of PowerMac and 68K
  88.     }}
  89. };
  90.  
  91. // rule that adds both PowerMac and 68K packages
  92. resource 'inrl' (1000) {
  93.     format0 {{
  94.         
  95.         // add both PowerMac and 68K packages to Custom Install selections
  96.         AddCustomItems{{ kPowerMacPackage, kSeperatorLine, k68000Package }},
  97.     }}
  98. };
  99.  
  100.  
  101. // • packages
  102.  
  103. // Power Macintosh
  104. resource 'inpk' ( kPowerMacPackage ) {
  105.     format0 {
  106.         showsOnCustom,            // if a subpackage, show in Custom Install
  107.         removable,                // include as a removeable item
  108.         dontForceRestart,        // don't make user reboot after installation
  109.         kPowerMacPackage,        // ID of package comments ( 'inpc' ), defined below
  110.         0,                        // Package size ( if 0, filled in by ScriptCheck )
  111.         
  112.         "PowerMac - TeachText to \"PowerMac Rules Example\" folder.",        
  113.                                 // Custom Install selection text
  114.                                 
  115.                                 
  116.         {        // Package parts list ( all the stuff to be include in package )
  117.                 // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
  118.                 // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
  119.                                                                 
  120.         'infa', 1075;            // PowerMac compatable file
  121.         },
  122.     }
  123. };
  124.  
  125.  
  126. // seperator line in Custom Install list of options
  127. resource 'inpk' ( kSeperatorLine ) {
  128.     format0 {
  129.         showsOnCustom,            // if a subpackage, show in Custom Install
  130.         
  131.         notRemovable,            // don't allow selection of seperator line 
  132.                                 // for removal
  133.                                 
  134.         dontForceRestart,        // don't make user reboot after installation
  135.         0,                        // no comments for a seperator line
  136.         0,                        // no size for a seperator line
  137.         "-",                    // display a dashed line in Custom Install 
  138.         {    
  139.                                 // parts list is empty for seperator line
  140.         },
  141.     }
  142. };
  143.  
  144. // 7.5 or greater
  145. resource 'inpk' ( k68000Package ) {
  146.     format0 {
  147.         showsOnCustom,            // if a subpackage, show in Custom Install
  148.         removable,                // include as a removeable item
  149.         dontForceRestart,        // don't make user reboot after installation
  150.         k68000Package,            // ID of package comments ( 'inpc' ), defined below
  151.         0,                        // Package size ( if 0, filled in by ScriptCheck )
  152.         
  153.         "68K - TeachText to \"PowerMac Rules Example\" folder.",        
  154.                                 // Custom Install selection text
  155.                                 
  156.                                 
  157.         {        // Package parts list ( all the stuff to be include in package )
  158.                 // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
  159.                 // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
  160.                                 
  161.         'infa', 1070;            // 68K compatable file
  162.         },
  163.     }
  164. };
  165.  
  166.  
  167.  
  168. // • package comments
  169.  
  170. // NOTE: The actual file that will be installed in either package is actually 
  171. // TeachText. The information detailed below does not actually correspond to 
  172. // the file being installed and is intended only as an example of how to prepare 
  173. // custom package information resources.
  174.  
  175. // FURTHER NOTE: The values that are assigned to the Custom Package Information 
  176. // resource fields do not actually have any effect on the installation and are 
  177. // ignored during installation. They can however assist the user in choosing which 
  178. // packages they would like to include in their Custom Installation or Custom Removal.
  179.  
  180. // The following included file contains the icons for the two package comments.
  181. // I created the file with the icon resources ( in this case 'icl4' and 'icl8' )
  182. // by opening the application to be installed within ResEdit. I then copied the
  183. // 'ICN#', 'icl4' and 'icl8' icon resources into a new ResEdit file called 
  184. // "Icons.rsrc" and assigned the resource items an ID of 9128, since their original 
  185. // resource ID's had a value that was illegal for use with 'inpc' resources 
  186. // ( they must be over 1024 ).
  187. // - An alternative to this method is to derez the application and to paste the 
  188. // resulting resource definitions into this script file and to let the Rez command 
  189. // build the icons every time that the installer script is Rezzed. If you happen 
  190. // to forget to include the resources for the icons, ScriptCheck will complain, 
  191. // but you will still be able to use the Rezzed installer script to successfully 
  192. // perform an installation. 
  193. include "Icons.rsrc";
  194.  
  195. resource 'inpc' ( kPowerMacPackage ) {
  196.     format1 {
  197.         8021994,                // sample date ( 08/02/94 )
  198.         403,                    // sample version ( 4.0.3 )
  199.         
  200.         2500 * 1024,            // RAM required for package ( 2.5 megabytes )
  201.         
  202.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  203.                                 // - ID must be greater than 1024
  204.                                 // - resource item in rezzed script file
  205.                                 
  206.         kPowerMacPackage,        // 'TEXT' resource ID of item  
  207.                                 // containing package description
  208.         
  209.     }
  210. };
  211.  
  212. resource 'inpc' ( k68000Package ) {
  213.     format1 {
  214.         8021994,                // sample date ( 08/02/94 )
  215.         403,                    // sample version ( 4.0.3 )
  216.  
  217.         4250 * 1024,            // RAM required for package ( 4.25 megabytes )
  218.         
  219.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  220.                                 // - ID must be greater than 1024
  221.                                 // - resource item in rezzed script file
  222.  
  223.         k68000Package,            // 'TEXT' resource ID of item  
  224.                                 // containing package description
  225.     }
  226. };
  227.  
  228.  
  229. // The following resource items can easily be created manually by creating 'TEXT' 
  230. //  resource items in a file and including that file in this script.
  231. // USE: include "fileWithTextItem.rsrc";    
  232. // NOTE : resource includes use "include" instead of "#include" 
  233. //         and are terminated with a semicolon.
  234. data 'TEXT' ( kPowerMacPackage ) {
  235.     "This is some sample text that would describe what the Power Macintosh "
  236.     "compatible package contains."
  237. };
  238.  
  239. data 'TEXT' ( k68000Package ) {
  240.     "This is some sample text that would describe what the 68000 CPU compatible "
  241.     "package contains."
  242. };
  243.  
  244.  
  245.  
  246. // • file atoms
  247.  
  248. // file atom for PowerMac version
  249. resource 'infa' (1075) {
  250.     format1 {
  251.         deleteWhenRemoving,
  252.         deleteWhenInstalling,
  253.         copy,                        
  254.         dontIgnoreLockedFile,
  255.         dontSetFileLocked,
  256.         useSrcCrDateToCompare,        
  257.         srcNeedExist,
  258.         rsrcForkInRsrcFork,
  259.         leaveAloneIfNewer,            
  260.         updateExisting,                
  261.         copyIfNewOrUpdate,
  262.         rsrcFork,
  263.         dataFork,
  264.         0,
  265.         0x0,
  266.         10075,
  267.         {    
  268.             10076, 
  269.             0, 
  270.             0    
  271.         },
  272.         0,                            
  273.         0,
  274.         0,
  275.         "TeachText • PowerMac"
  276.     }
  277. };
  278.  
  279. // file atom for 68K version
  280. resource 'infa' (1070) {
  281.     format1 {
  282.         deleteWhenRemoving,
  283.         deleteWhenInstalling,
  284.         copy,                        
  285.         dontIgnoreLockedFile,
  286.         dontSetFileLocked,
  287.         useSrcCrDateToCompare,        
  288.         srcNeedExist,
  289.         rsrcForkInRsrcFork,
  290.         leaveAloneIfNewer,            
  291.         updateExisting,                
  292.         copyIfNewOrUpdate,
  293.         rsrcFork,
  294.         dataFork,
  295.         0,
  296.         0x0,
  297.         10070,
  298.         {    
  299.             10071, 
  300.             0, 
  301.             0    
  302.         },
  303.         0,                            
  304.         0,
  305.         0,
  306.         "TeachText • 68K"
  307.     }
  308. };
  309.  
  310.  
  311. // • file specs
  312.  
  313. // target file spec for TeachText application
  314. resource 'intf' (10075) {
  315.     format1 {
  316.         noSearchForFile,                 // use default search path
  317.         
  318.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  319.                                         // then a file with a different type
  320.                                         // and creator than those specified
  321.                                         // below will not be replaced.
  322.                                         // If this is set to TypeCrNeedNotMatch
  323.                                         // then type and creator of an existing
  324.                                         // target file are ignored.
  325.         
  326.         // The Type and Creator fields will be used to set the
  327.         // file's Type and Creator when a new file is created. 
  328.         'APPL',                         // TYPE for new file
  329.         'ttxt',                         // CREATOR for new file
  330.         
  331.         0,                                 // finder attribute flags
  332.                                         // filled by ScriptCheck is value is 0
  333.         
  334.         1,                                  // creation date for new file
  335.         1,                                  // modification date for new file
  336.                                         // NOTE: DATE values are filled
  337.                                         // by ScriptCheck if the value is 1
  338.                                             
  339.         0,                                 // search proc ID ( 'insp' ), none used
  340.         
  341.         ":PowerMac Rules Example:TeachText • PowerMac" // path to target file
  342.         }
  343.     };
  344.  
  345.  
  346. // source file spec for TeachText application
  347. resource 'infs' (10076) {
  348.     'APPL',                        // TYPE for file search
  349.     'ttxt',                        // CREATOR for file search
  350.     
  351.     0x1,                        // creation DATE for source file
  352.                                 // ( value of 1, filled in by ScriptCheck
  353.                                 
  354.     noSearchForFile,            // IGNORED in Installer 4.0.x
  355.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  356.     "Disk 1:TeachText • PowerMac"    // PATH to source file        
  357. };
  358.  
  359.  
  360. // target file spec for TeachText application
  361. resource 'intf' (10070) {
  362.     format1 {
  363.         noSearchForFile,                 // use default search path
  364.         
  365.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  366.                                         // then a file with a different type
  367.                                         // and creator than those specified
  368.                                         // below will not be replaced.
  369.                                         // If this is set to TypeCrNeedNotMatch
  370.                                         // then type and creator of an existing
  371.                                         // target file are ignored.
  372.         
  373.         // The Type and Creator fields will be used to set the
  374.         // file's Type and Creator when a new file is created. 
  375.         'APPL',                         // TYPE for new file
  376.         'ttxt',                         // CREATOR for new file
  377.         
  378.         0,                                 // finder attribute flags
  379.                                         // filled by ScriptCheck is value is 0
  380.         
  381.         1,                                  // creation date for new file
  382.         1,                                  // modification date for new file
  383.                                         // NOTE: DATE values are filled
  384.                                         // by ScriptCheck if the value is 1
  385.                                             
  386.         0,                                 // search proc ID ( 'insp' ), none used
  387.         
  388.         ":PowerMac Rules Example:TeachText • 68K" // path to target file
  389.         }
  390.     };
  391.  
  392. // source file spec for TeachText application
  393. resource 'infs' (10071) {
  394.     'APPL',                        // TYPE for file search
  395.     'ttxt',                        // CREATOR for file search
  396.     
  397.     0x1,                        // creation DATE for source file
  398.                                 // ( value of 1, filled in by ScriptCheck
  399.                                 
  400.     noSearchForFile,            // IGNORED in Installer 4.0.x
  401.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  402.     "Disk 1:TeachText • 68K"        // PATH to source file        
  403. };
  404.  
  405.  
  406.